package com.jtattoo.demo.app;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author michael hagen
 */
public class TabRenderingProblem {

    public static void main(String[] args) {

        try {
            UIManager.setLookAndFeel(new com.jtattoo.plaf.luna.LunaLookAndFeel());
        } catch (UnsupportedLookAndFeelException e) {
        }

        JFrame frame = new JFrame();
        frame.setLayout(new BorderLayout());

        final JLabel label = new JLabel("NDERBARER TEXT");

        JTabbedPane tabbedPane = new JTabbedPane();
        JPanel panel1 = new JPanel();
        JPanel panel2 = new JPanel();

        frame.add(tabbedPane, BorderLayout.CENTER);
        tabbedPane.add("panel 1", panel1);
        tabbedPane.add("panel 2", panel2);

        tabbedPane.setTabComponentAt(0, label);
        tabbedPane.setTabComponentAt(1, new JLabel("ohne text"));
        JButton button = new JButton("change font");
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (label.getFont().getStyle() == Font.PLAIN) {

                    label.setFont(new Font("Dialog", Font.BOLD, 11));
                } else {
                    label.setFont(new Font("Dialog", Font.PLAIN, 9));
                }

            }
        });

        frame.add(button, BorderLayout.SOUTH);

        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }

        });

        frame.setSize(500, 200);
        frame.setVisible(true);

    }
}
